/* QtLua -- Lua bindings for Qt
   Copyright (C) 2011, Jarek Pelczar

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General
   Public License along with this library; if not, write to the
   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301 USA

*/

#include "qluascriptdebuggerscripteditor_p.h"
#include "qluascripteditor_p.h"
#include <QVBoxLayout>

QLuaScriptDebuggerScriptEditor::QLuaScriptDebuggerScriptEditor(QWidget *parent) :
    QLuaScriptDebuggerScriptEditorInterface(parent)
{
    QVBoxLayout * l = new QVBoxLayout(this);

    m_editor = new QLuaScriptEditor(this);
    m_editor->setReadOnly(true);
    m_editor->setBackgroundVisible(true);

    l->setMargin(0);
    l->addWidget(m_editor);

    m_lastId = -1;
}

QLuaScriptDebuggerScriptEditor::~QLuaScriptDebuggerScriptEditor()
{
}

QString QLuaScriptDebuggerScriptEditor::text() const
{
    return m_editor->toPlainText();
}

void QLuaScriptDebuggerScriptEditor::setText(const QString& str)
{
    m_editor->setPlainText(str);
}

int QLuaScriptDebuggerScriptEditor::cursorLineNumber() const
{
    return m_editor->currentLineNumber();
}

void QLuaScriptDebuggerScriptEditor::gotoLine(int lineNumber)
{
    m_editor->gotoLine(lineNumber);
}

qint64 QLuaScriptDebuggerScriptEditor::currentScriptId() const
{
    return m_lastId;
}

void QLuaScriptDebuggerScriptEditor::setScriptId(qint64 id)
{
    m_lastId = id;
}

int QLuaScriptDebuggerScriptEditor::executionLineNumber() const
{
    return m_editor->executionLineNumber();
}

void QLuaScriptDebuggerScriptEditor::setExecutionLineNumber(int lineNumber, bool error)
{
    m_editor->setExecutionLineNumber(lineNumber, error);
}

void QLuaScriptDebuggerScriptEditor::setExecutableLineNumbers(const QSet<int> &lineNumbers)
{
    m_editor->setExecutableLineNumbers(lineNumbers);
}

bool QLuaScriptDebuggerScriptEditor::isExecutableLine(int lineNumber) const
{
    return m_editor->isExecutableLine(lineNumber);
}
